home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / xc1.arc / XC.C < prev    next >
Text File  |  1986-07-14  |  103KB  |  2,129 lines

  1. /***********************************************************/
  2. /*    XC.C                                                 */
  3. /*                                                         */
  4. /*    Last modified:    11:00   14 July  86     L.P.       */
  5. /*    Version 1.16                                         */
  6. /*                                                         */
  7. /*    Abstract:                                            */
  8. /*                                                         */
  9. /*    'XC' is a cross-reference utility for 'C' programs.  */
  10. /*    Its has the ability to handle nested include files   */
  11. /*    to a depth of 8 levels and properly processes nested */
  12. /*    comments as supported by BDS C. Option flags support */
  13. /*    the following features:                              */
  14. /*                                                         */
  15. /*    - Routing of list output to disk                     */
  16. /*    - Cross-referencing of reserved words                */
  17. /*    - Processing of nested include files                 */
  18. /*    - Generation of listing only                         */
  19. /*                                                         */
  20. /*    Usage: xc <filename> <flag(s)>                       */
  21. /*                                                         */
  22. /*    Flags: -i            = Enable file inclusion         */
  23. /*           -l            = Generate listing only         */
  24. /*           -c            = Compressed print listing      */
  25. /*           -r            = Cross-ref reserved words      */
  26. /*           -o <filename> = Write output to named file    */
  27. /*                                                         */
  28. /*************************************************************************/
  29. /*  7-2-86  Changes                     L. Paper                         */
  30. /*     - WARNING.  LINK TO THE _MAIN WHICH WAS NOT COMPILED WITH TINY    */
  31. /*            DEFINED UNDER LATTICE C, VER. 3.0. Lattice shipped my copy */
  32. /*            with _MAIN compiled with TINY.                             */
  33. /*     - Changed -c from always setting the output file to PRN to only   */
  34. /*            setting it to PRN if -o has not been read.                 */
  35. /*     - Changed -o option to accept either a space after the option or  */
  36. /*            the output file name immediately after the "c".            */
  37. /*     - Changed the usage display in use_err() to show the default      */
  38. /*            output for the -c option.                                  */
  39. /*     - Allow the input file name anywhere on the command line.         */
  40. /*     - Changed header string for Epson FX to DOUBLE STRIKE             */
  41. /*            COMPRESSED.                                                */
  42. /*     - Removed final trailing '.' when printing cross-references to a  */
  43. /*            file.                                                      */
  44. /*     - Changed display output when listing to a file from a period to  */
  45. /*            a digit.  Added text to separate display output '.'s when  */
  46. /*            cross-referencing from these numbers.                      */
  47. /*     - Added -t option to reset tab default from command line.         */
  48. /*     - Added compile time switch for Lattice C Ver. 3.                 */
  49. /*     - Included dos.h,  correctec reg and changed int86(0x21, to       */
  50. /*            intdos(... for Lattice C.                                  */
  51. /*     - Simplified the original and corrected date and time section for */
  52. /*            both the Computer Innovations compiler and Lattice C       */
  53. /*            Version 2 by the proprocessor variables REG and INT21.     */
  54. /*     - Eliminated all DOS calls for Lattice C, Ver. 3 with the new     */
  55. /*            functions getft and getclk.                                */
  56. /*     - Added the pointer variable next_ref to the struct rf_blk to     */
  57. /*            allow for different sizes of pointers.                     */
  58. /*     - Changed program to reflect new data structure.                  */
  59. /*     - Removed spurious cross-reference line when the last line had    */
  60. /*            exactly eight references and added a blank line between    */
  61. /*            variables.                                                 */
  62. /*     - Added \ to include file names for Lattice C, Ver. 3, which      */
  63. /*            accepts path names                                         */
  64. /*     - Added code to free dynamic storage after its contents are       */
  65. /*            printed.                                                   */
  66. /*     - For LATTICE C VERSION 3 compilation only, changed -i option     */
  67. /*       so it searches for #include files in subdirectories which       */
  68. /*       are named in the environment variable with the same name as the */
  69. /*       extension of the include file's name, then in subdirectories    */
  70. /*       which are named in the environment variable INCLUDE.  Added a   */
  71. /*       -in option which searches only for the file name as specified.  */
  72. /*************************************************************************/
  73. /*  5-20-86  Changes                    L. Paper                         */
  74. /*     - WARNING.  COMPILE WITH THE -w SWITCH SET UNDER LATTICE C VER.   */
  75. /*            3.0, at least for the small model.                         */
  76. /*     - Made several small changes to compile under Lattice C ver 3.0.  */
  77. /*     - Replaced PRN: with PRN for the -c option.                       */
  78. /*     - Increased length of file names for maximum path.                */
  79. /*     - Added default .c extension for input file.                      */
  80. /*     - Changed trailer string for Epson FX to EMPHASIZED PICA.         */
  81. /*     - Modified printing of trailer string so it is only with -c       */
  82. /*            option, and then before EOF, not after it.                 */
  83. /*************************************************************************/
  84. /*  5-20-84  Changes                    R.S. White                       */
  85. /*     - made compilation for Lattice C ver 2.0 or Computer Innovations  */
  86. /*            CI-C86 optional by setting #define labels accordingly.     */
  87. /*     - made printer selection for compressed print selectable by       */
  88. /*            setting #define labels accordingly.  Added Epson FX and    */
  89. /*            Gemini-10X printer control strings.                        */
  90. /*************************************************************************/
  91. /*  1-01-84  Enhancements               S.R. Jacobson                    */
  92. /*     - changed -e option to -c option and added two strings:           */
  93. /*            cprint_hdr sets the printer to compressed print mode       */
  94. /*            cprint_trlr resets the printer to "normal" mode            */
  95. /*         This makes it easier for non-epson printer users              */
  96. /*     -  removed all the BDS C comments (this makes it easier to modify */
  97. /*            in the future.                                             */
  98. /*     -  changed name of the utility to the "print" utility             */
  99. /*     -  if the -i flag is not used, the second line number will not    */
  100. /*            appear.                                                    */
  101. /*     -  if a form feed is detected in the source file, a new page is   */
  102. /*            started.  This is useful for structuring the source        */
  103. /*            code by placing each major section on a separate page.     */
  104. /*            You do this by embedding a form feed (control L) in a      */
  105. /*            comment.  The text following the form feed will be placed  */
  106. /*            on the top of the new page.                                */
  107. /*     -  tab characters in the file are expanded to every 8 positions.  */
  108. /*            This may be changed by changing the TABCNT define.         */
  109. /*     -  added the date and time to the printed output. (C-86 only)     */
  110. /*     -  fixed error in hashing algorithm.                              */
  111. /*     -  control characters (other than \n, \f, or \t) are stripped     */
  112. /*            from the input stream (converted to blanks).  This         */
  113. /*            prevents extraneous control chars from interfering with    */
  114. /*            operation of xc.                                           */
  115. /*     -  cleaned up the structuring of a number of routines.            */
  116. /*     -  added the file latest update date and time to the printed      */
  117. /*            output. ***DOS 2.0 ONLY ***                                */
  118. /*************************************************************************/
  119. /*   9-26-83   Microsoft C 1.04  Conversion    WHR                       */
  120. /*     -  \t between line numbers and text to fix indenting problem.     */
  121. /*     -  added option -e for output to Epson in condensed print.        */
  122. /*     -  toupper() and isupper() are macros, not functions.             */
  123. /*     -  eliminate side effect in toupper(*++arg) in main().            */
  124. /*     -  change alloc() to malloc().                                    */
  125. /*     -  add #define NAMES that are not in stdio.h                      */
  126. /*     -  MS-C requires () in statement A?(c=B):(c=C)   error or not??   */
  127. /*                                                                       */
  128. /*   4-30-83   Computer Innovations C-86 1.31 Conversion    WHR          */
  129. /*     -  #include filename changed to allow a disk drive prefix, D:     */
  130. /*     -  convert if(fprintf(...) == ERROR) lst_err(); to fprintf(..);   */
  131. /*     -  convert if(fopen(...) == ERROR) statements to == NUL0.         */
  132. /*     -  C86 requires () in statement A?(c=B):(c=C)    error or not??   */
  133. /*     -  remove getc() == ERROR check in fil_chr().                     */
  134. /*     -  convert file conventions from BDS C to C-86.                   */
  135. /*     -  comment out BDS unique statements, mark revised statements.    */
  136. /*        keep all BDS statements to document conversion effort.         */
  137. /*                                                                       */
  138. /**  4-19-83   BDS C Version file XC.CQ copied from Laurel RCPM    WHR   */
  139. /*************************************************************************/
  140. /*   ** Original Version: **                               */
  141. /*                                                         */
  142. /*    Version 1.0   January, 1982                          */
  143. /*                                                         */
  144. /*    Copyright (c) 1982 by Philip N. Hisley               */
  145. /*                                                         */
  146. /*    Released for non-commercial distribution only        */
  147. /*                                                         */
  148. /*    Please report bugs/fixes/enhancements to:            */
  149. /*                                                         */
  150. /*            Philip N. Hisley                             */
  151. /*            548H Jamestown Court                         */
  152. /*            Edgewood, Maryland 21040                     */
  153. /*            (301) 679-4606                               */
  154. /*            Net Addr: PNH@MIT-AI                         */
  155. /*                                                         */
  156. /*                                                         */
  157. /***********************************************************/
  158.  
  159. /*   DEFINITIONS AND VARIABLES  */                                      /*SRJ*/
  160.  
  161. #define  LATTICE2 0     /* Set to use Lattice C Ver. 2.x compiler.  LP */
  162. #define  LATTICE3 1     /* Set to use Lattice C Ver. 3.0 compiler.  LP */
  163. #define CIC86   0       /* disable Computer Innovations compiler */     /*RSW*/
  164.  
  165. #define GEMIN10X 0      /* enable Gemini-10X printer codes      */      /*RSW*/
  166. #define EPSONMX  0                                                      /*RSW*/
  167. #define EPSONFX  1                                                      /*RSW*/
  168. #define IDSPRISM 0                                                      /*RSW*/
  169.  
  170. #define  TAB_DFLT 3     /* Default value for tab_cnt.  XC expands */
  171. /* tabs to every tab_cnt characters.  LP */
  172.  
  173. /*************************************************************************/
  174. /*                                                                       */
  175. /* This section and the functions at the end of the program are          */
  176. /* compiler-sensitive.  Since I do not now have access to Lattice C,     */
  177. /* Version 2 or to Computer Innovations C-86, I may have unwittingly     */
  178. /* introduced some bugs by adding switches and moving code.              */
  179. /*                                                                       */
  180. /* The last #else represents my best guess as to what other compilers    */
  181. /* might do.  I have not tried to guess in all cases, so other           */
  182. /* compilers will have some undefined symbols which the programmer       */
  183. /* must adapt.                                                           */
  184. /*                                                                       */
  185.  
  186. /* --------------- Include files                                     */ /*LP*/
  187.  
  188. #if CIC86                                                               /*LP*/
  189. #include <stdio.h>                                                      /*WHR*/
  190. #else                                                                   /*LP*/
  191.  
  192. #if LATTICE2                                                            /*LP*/
  193. #include <stdio.h>                                                      /*WHR*/
  194. #include <ctype.h>      /* Lattice C ver 2.0 and 3.0 - macros */        /*RSW*/
  195. #else                                                                   /*LP*/
  196.  
  197. #if LATTICE3                                                            /*LP*/
  198. #include <stdio.h>                                                      /*WHR*/
  199. #include <stdlib.h>                                                     /*LP*/
  200. #include <dos.h>        /* Also defines LATTICE as 1 */                 /*LP*/
  201. #include <string.h>                                                     /*LP*/
  202. #include <ctype.h>      /* Lattice C ver 2.0 and 3.0 - macros */        /*RSW*/
  203.  
  204. #else                                           /* Other */             /*LP*/
  205. #include <stdio.h>                                                      /*WHR*/
  206. #endif                                          /* LATTICE3 */          /*LP*/
  207. #endif                                          /* LATTICE2 */          /*LP*/
  208. #endif                                          /* CIC86 */             /*LP*/
  209.  
  210. /* --------------- LATTICE preprocessor variable                     */ /*LP*/
  211.  
  212. #if CIC86                                                               /*LP*/
  213. #define LATTICE 0                                                       /*LP*/
  214. #else                                                                   /*LP*/
  215. #if LATTICE2                                                            /*LP*/
  216. #define LATTICE 1       /* set to use Lattice C ver 2.0 compiler */     /*RSW*/
  217. #else                                                                   /*LP*/
  218. #if LATTICE3                                                            /*LP*/
  219. /* Defined as 1 in dos.h */                                             /*LP*/
  220. #else                                           /* Other */             /*LP*/
  221. #define LATTICE 0                                                       /*LP*/
  222. #endif                                          /* LATTICE3 */          /*LP*/
  223. #endif                                          /* LATTICE2 */          /*LP*/
  224. #endif                                          /* CIC86 */             /*LP*/
  225.  
  226. /* --------------- void type                                         */ /*LP*/
  227.  
  228. #if CIC86                                                               /*LP*/
  229. #define void int                                                        /*LP*/
  230. #else                                                                   /*LP*/
  231. #if LATTICE2                                                            /*LP*/
  232. #define void int                                                        /*LP*/
  233. #else                                                                   /*LP*/
  234. #if LATTICE3                                                            /*LP*/
  235. /* void is defined in Lattice, Version 3 */
  236. #else                                           /* Other */             /*LP*/
  237. #define void int                                                        /*LP*/
  238. #endif                                          /* LATTICE3 */          /*LP*/
  239. #endif                                          /* LATTICE2 */          /*LP*/
  240. #endif                                          /* CIC86 */             /*LP*/
  241.  
  242. /* --------------- Function prototyping control                      */ /*LP*/
  243. /* Lattice C, Version 3 enables function prototyping unless NARGS is */ /*LP*/
  244. /* is defined.  If your compiler uses a different method, adjust     */ /*LP*/
  245. /* this subsection.                                                  */ /*LP*/
  246.  
  247. #if CIC86                                                               /*LP*/
  248. #define NARGS                                                           /*LP*/
  249. #else                                                                   /*LP*/
  250. #if LATTICE2                                                            /*LP*/
  251. #define NARGS                                                           /*LP*/
  252. #else                                                                   /*LP*/
  253. #if LATTICE3                                                            /*LP*/
  254. /* Leave NARGS undefined to enable function prototyping */              /*LP*/
  255. #else                                           /* Other */             /*LP*/
  256. /* Assume the other compiler does not implement function prototyping */ /*LP*/
  257. #define NARGS                                                           /*LP*/
  258. #endif                                          /* LATTICE3 */          /*LP*/
  259. #endif                                          /* LATTICE2 */          /*LP*/
  260. #endif                                          /* CIC86 */             /*LP*/
  261.  
  262. /* --------------- Library function declarations                     */ /*LP*/
  263.  
  264. #if CIC86                                                               /*LP*/
  265.    void segread();                                                      /*LP*/
  266.    void sysint();                                                       /*LP*/
  267.    char *strcpy();
  268.    char *strchr(), *strcat();                                           /*LP*/
  269.    int  toupper();      /* toupper in Lattice C is a macro with side effects */
  270.                                                                         /*LP*/
  271. #else                                                                   /*LP*/
  272.  
  273. #if LATTICE2                                                            /*LP*/
  274.    int  dosint();                                                       /*LP*/
  275.    char *strcpy();
  276.    char *strchr(), *strcat();                                           /*LP*/
  277.    int  fileno();                                                       /*LP*/
  278. #else                                                                   /*LP*/
  279.  
  280. #if LATTICE3                                                            /*LP*/
  281. /* Declared by included files                                        */ /*LP*/
  282.  
  283. #else                                           /* Other */             /*LP*/
  284.    char *strcpy();
  285.    char *strchr(), *strcat();                                           /*LP*/
  286.    int  toupper();      /* toupper in Lattice C is a macro with side effects */
  287.                                                                         /*LP*/
  288.    int  fileno();                                                       /*LP*/
  289. #endif                                          /* LATTICE3 */          /*LP*/
  290. #endif                                          /* LATTICE2 */          /*LP*/
  291. #endif                                          /* CIC86 */             /*LP*/
  292.  
  293.  
  294. /* --------------- struct rf_blk                                     */ /*LP*/
  295.  
  296. #define  MAX_REF    5                   /* maximum refs per ref-block */
  297.  
  298. #if CIC86                                                               /*LP*/
  299. struct  rf_blk
  300. {
  301.    int  ref_item[MAX_REF];
  302.    int  ref_cnt;
  303. } onerf;
  304. #define NEXT_REF ref_cnt                                                /*LP*/
  305. #define IS_PTR(rf_ptr) rf_ptr > (struct rf_blk *) MAX_REF               /*LP*/
  306. #else                                                                   /*LP*/
  307.  
  308. #if LATTICE                                                             /*LP*/
  309. struct  rf_blk
  310. {
  311.    int  ref_item[MAX_REF];
  312.    int  ref_cnt;
  313.    struct rf_blk *next_ref;                                             /*LP*/
  314. } onerf;
  315. #define NEXT_REF next_ref                                               /*LP*/
  316. #define IS_PTR(rf_ptr) rf_ptr   /* TRUE if rf_ptr is not NULL */        /*LP*/
  317. #else                                           /* Other */             /*LP*/
  318.  
  319. struct  rf_blk
  320. {
  321.    int  ref_item[MAX_REF];
  322.    int  ref_cnt;
  323.    struct rf_blk *next_ref;                                             /*LP*/
  324. } onerf;
  325. #define NEXT_REF next_ref                                               /*LP*/
  326. #define IS_PTR(rf_ptr) rf_ptr   /* TRUE if rf_ptr is not NULL */        /*LP*/
  327. #endif                                          /* LATTICE */           /*LP*/
  328. #endif                                          /* CIC86 */             /*LP*/
  329.  
  330. /* --------------- DOS interrupt pre-processor definitions           */ /*LP*/
  331.  
  332. #if CIC86                                                               /*LP*/
  333. #define INT21 sysint(0x21,&creg,&creg)          /* DOS interrupt.  LP */
  334. struct       regval
  335. {
  336.    unsigned int ax,bx,cx,dx,si,di,ds,es;
  337. }
  338. creg; /*structure for sysint*/                                          /*SRJ*/
  339. #define REG creg                                                        /*LP*/
  340.  
  341. struct       regv
  342. {
  343.    unsigned int csx,ssx,dsx,esx;
  344. } regx;                                 /* structure for segread*/      /*SRJ*/
  345.  
  346. unsigned int    handle;                         /* dos file handle */   /*SRJ*/
  347. #else                                                                   /*LP*/
  348.  
  349. #if LATTICE2                                                            /*LP*/
  350. #define INT21 (void) intdos(&lreg, &lreg)       /* DOS interrupt.  LP */
  351. union REGS lreg;                                                        /*LP*/
  352. #define REG lreg.x                                                      /*LP*/
  353.  
  354. unsigned int    handle;                         /* dos file handle */   /*SRJ*/
  355. #else                                                                   /*LP*/
  356.  
  357. #if LATTICE3                                                            /*LP*/
  358. /* No DOS interrupts for Lattice, Ver. 3 */
  359. #else                                           /* Other */             /*LP*/
  360.  
  361. /* No standard for DOS interrupts for other compilers */
  362.  
  363. unsigned int    handle;                         /* dos file handle */   /*SRJ*/
  364. #endif                                          /* LATTICE3 */          /*LP*/
  365. #endif                                          /* LATTICE2 */          /*LP*/
  366. #endif                                          /* CIC86 */             /*LP*/
  367.  
  368. /* --------------- Control side effect of toupper() as a macro       */ /*LP*/
  369.  
  370. #if CIC86                                                               /*LP*/
  371. #define SIDE_1  0                                                       /*LP*/
  372. #else                                                                   /*LP*/
  373. #if LATTICE                                                             /*LP*/
  374. #define SIDE_1  1                                                       /*LP*/
  375. #else                                           /* Other */             /*LP*/
  376. #define SIDE_1  1               /* Conservative assumption */           /*LP*/
  377. #endif                                          /* LATTICE */           /*LP*/
  378. #endif                                          /* CIC86 */             /*LP*/
  379.  
  380. /* --------------- Get the system date and time                      */ /*LP*/
  381.  
  382. #if CIC86                                                               /*LP*/
  383. #define GETCLOK getclk_1                                                /*LP*/
  384. #else                                                                   /*LP*/
  385. #if LATTICE2                                                            /*LP*/
  386. #define GETCLOK getclk_2                                                /*LP*/
  387. #else                                                                   /*LP*/
  388. #if LATTICE3                                                            /*LP*/
  389. #define GETCLOK getclk_3                                                /*LP*/
  390. #else                                           /* Other */             /*LP*/
  391. #endif                                          /* LATTICE3 */          /*LP*/
  392. #endif                                          /* LATTICE2 */          /*LP*/
  393. #endif                                          /* CIC86 */             /*LP*/
  394.  
  395. /* --------------- Get file gbl_fil's date and time                  */ /*LP*/
  396.  
  397. #if CIC86                                                               /*LP*/
  398. #define GETFTM getft_1                                                  /*LP*/
  399. #else                                                                   /*LP*/
  400. #if LATTICE2                                                            /*LP*/
  401. #define GETFTM  getft_2                                                 /*LP*/
  402. #else                                                                   /*LP*/
  403. #if LATTICE3                                                            /*LP*/
  404. #define GETFTM  getft_3                                                 /*LP*/
  405. #else                                           /* Other */             /*LP*/
  406. #endif                                          /* LATTICE3 */          /*LP*/
  407. #endif                                          /* LATTICE2 */          /*LP*/
  408. #endif                                          /* CIC86 */             /*LP*/
  409.  
  410. /* --------------- Test whether l_buffer is a file                   */ /*LP*/
  411.  
  412. #if CIC86                                                               /*LP*/
  413. /* The code in get_ft1 implies that there is no way for Computer     */ /*LP*/
  414. /* Innovations C-86 to find the handle of a file which it opens      */ /*LP*/
  415. /* with an fopen function.  In addition, it implies that the flags   */ /*LP*/
  416. /* are not available from sysint.  If this is true, there is no way  */ /*LP*/
  417. /* to test whether l_buffer is a file without closing it.  Since     */ /*LP*/
  418. /* the purpose of the test is to avoid closing a device, use a       */ /*LP*/
  419. /* dummy test.                                                       */ /*LP*/
  420. #define L_IS_FIL l_isf0                                                 /*LP*/
  421. #else                                                                   /*LP*/
  422. #if LATTICE2                                                            /*LP*/
  423. #define L_IS_FIL l_isf2                                                 /*LP*/
  424. #else                                                                   /*LP*/
  425. #if LATTICE3                                                            /*LP*/
  426. #define L_IS_FIL l_isf3                                                 /*LP*/
  427. #else                                                                   /*LP*/
  428. /* Assumes the other compiler can not check whether l_buffer is a */    /*LP*/
  429. /* file                                                           */    /*LP*/
  430. #define L_IS_FIL l_isf0                                                 /*LP*/
  431. #endif                                          /* LATTICE3 */          /*LP*/
  432. #endif                                          /* LATTICE2 */          /*LP*/
  433. #endif                                          /* CIC86 */             /*LP*/
  434.  
  435. /* --------------- Flush l_buffer if necessary                       */ /*LP*/
  436.  
  437. #if CIC86                                                               /*LP*/
  438. #define L_FLUSH l_fl1                                                   /*LP*/
  439. #else                                                                   /*LP*/
  440. #if LATTICE                                                             /*LP*/
  441. #define L_FLUSH l_fl0                                                   /*LP*/
  442. #else                                                                   /*LP*/
  443. /* Assumes that other compiler does not need to flush l_buffer */       /*LP*/
  444. #define L_FLUSH l_fl0                                                   /*LP*/
  445. #endif                                          /* LATTICE */           /*LP*/
  446. #endif                                          /* CIC86 */             /*LP*/
  447.  
  448. /* --------------- Expression which is true for valid file name      */ /*LP*/
  449. /* --------------- character which is not alphanumeric of an         */ /*LP*/
  450. /* --------------- underscore.                                       */ /*LP*/
  451.  
  452. #if CIC86                                                               /*LP*/
  453. #define IS_PATH FALSE                                                   /*LP*/
  454. #define IS_FCHAR (c == '.' || c == ':')                 /* No path */   /*LP*/
  455. #else                                                                   /*LP*/
  456. #if LATTICE                                                             /*LP*/
  457. #define IS_PATH *g_token != '\\'                                        /*LP*/
  458. #define IS_FCHAR (c == '\\' || c == '.' || c == ':')    /* Path */      /*LP*/
  459. #else                                           /* Other */             /*LP*/
  460. #define IS_PATH FALSE                                                   /*LP*/
  461. #define IS_FCHAR (c == '.' || c == ':')         /* Assume no path */    /*LP*/
  462.  
  463. #endif                                          /* LATTICE */           /*LP*/
  464. #endif                                          /* CIC86 */             /*LP*/
  465.  
  466. /* --------------- Declare memory allocation functions               */ /*LP*/
  467.  
  468. #if CIC86                                                               /*LP*/
  469.    char *alloc();                                                       /*LP*/
  470. #define NULL_PTR 0                                                      /*LP*/
  471. #else                                                                   /*LP*/
  472.  
  473. #if LATTICE2                                                            /*LP*/
  474.    char *getmem();                                                      /*LP*/
  475.    int allmem();                                                        /*LP*/
  476.    void rstmem();                                                       /*LP*/
  477. #define NULL_PTR NULL                                                   /*LP*/
  478. #else                                                                   /*LP*/
  479.  
  480. #if LATTICE3                                                            /*LP*/
  481. /* Declared in header file STDLIB.H */                                  /*LP*/
  482. #define NULL_PTR NULL                                                   /*LP*/
  483. #else                                           /* Other */             /*LP*/
  484.  
  485. /* Assume the other compiler follows the UNIX standard */               /*LP*/
  486.    char *malloc();                                                      /*LP*/
  487. #define NULL_PTR NULL                                                   /*LP*/
  488. #endif                                          /* LATTICE3 */          /*LP*/
  489. #endif                                          /* LATTICE2 */          /*LP*/
  490. #endif                                          /* CIC86 */             /*LP*/
  491.  
  492. /* --------------- Functions to allocate an id_blk                   */ /*LP*/
  493.  
  494. #if CIC86                                                               /*LP*/
  495. #define ID_ALLOC alloc(sizeof(oneid))                                   /*LP*/
  496. #else                                                                   /*LP*/
  497.  
  498. #if LATTICE                                                             /*LP*/
  499. #define ID_ALLOC (struct id_blk *) getmem((unsigned) sizeof(oneid))     /*LP*/
  500.  
  501. #else                                           /* Other */             /*LP*/
  502. /* Assume the other compiler follows the UNIX standard */               /*LP*/
  503. #define ID_ALLOC (struct id_blk *) malloc((unsigned) sizeof(oneid))     /*LP*/
  504. #endif                                          /* LATTICE */           /*LP*/
  505. #endif                                          /* CIC86 */             /*LP*/
  506.  
  507. /* --------------- Functions to allocate and free a rf_blk          */  /*LP*/
  508.  
  509. #if CIC86                                                               /*LP*/
  510. #define RF_ALLOC alloc(sizeof(onerf))                                   /*LP*/
  511. #else                                                                   /*LP*/
  512.  
  513. #if LATTICE                                                             /*LP*/
  514. #define RF_ALLOC (struct rf_blk *) getmem((unsigned) sizeof(onerf))     /*LP*/
  515.  
  516. #else                                           /* Other */             /*LP*/
  517. /* Assume the other compiler follows the UNIX standard */               /*LP*/
  518. #define RF_ALLOC (struct rf_blk *) malloc((unsigned) sizeof(onerf))     /*LP*/
  519. #endif                                          /* LATTICE */           /*LP*/
  520. #endif                                          /* CIC86 */             /*LP*/
  521.  
  522. /* --------------- Lattice get and release dynamic memory            */ /*LP*/
  523. /* --------------- With luck, may prevent termination problems       */ /*LP*/
  524.  
  525. #if CIC86                                                               /*LP*/
  526. /* Dummy function for non-Lattice compilers */                          /*LP*/
  527. int d_dyn()                                                             /*LP*/
  528.  
  529. {                                                                       /*LP*/
  530.    return(0);                                                           /*LP*/
  531. }                                                                       /*LP*/
  532. #define GETDYN  d_dyn;                                                  /*LP*/
  533. #define RELDYN  (void) d_dyn;                                           /*LP*/
  534. #else                                                                   /*LP*/
  535.  
  536. #if LATTICE                                                             /*LP*/
  537. #define GETDYN  allmem                                                  /*LP*/
  538. #define RELDYN  rstmem                                                  /*LP*/
  539.  
  540. #else                                           /* Other */             /*LP*/
  541. /* Dummy function for non-Lattice compilers */                          /*LP*/
  542. int d_dyn()                                                             /*LP*/
  543.  
  544. {                                                                       /*LP*/
  545.    return(0);                                                           /*LP*/
  546. }                                                                       /*LP*/
  547. #define GETDYN  d_dyn;                                                  /*LP*/
  548. #define RELDYN  (void) d_dyn;                                           /*LP*/
  549. #endif                                          /* LATTICE */           /*LP*/
  550. #endif                                          /* CIC86 */             /*LP*/
  551.  
  552. /* --------------- Lattice Version 3 for include path                */ /*LP*/
  553.  
  554. #if CIC86                                                               /*LP*/
  555. #define IN_FALSE                                        /* Dummy */     /*LP*/
  556. #define CHK_IN                                          /* Dummy */     /*LP*/
  557. #define I_MESS  i_mes1                                                  /*LP*/
  558. #define OPEN_IN opn_i1                                                  /*LP*/
  559. #else                                                                   /*LP*/
  560.  
  561. #if LATTICE2                                                            /*LP*/
  562. #define IN_FALSE                                        /* Dummy */     /*LP*/
  563. #define CHK_IN                                          /* Dummy */     /*LP*/
  564. #define I_MESS  i_mes1                                                  /*LP*/
  565. #define OPEN_IN opn_i1                                                  /*LP*/
  566. #else                                                                   /*LP*/
  567.  
  568. #if LATTICE3                                                            /*LP*/
  569. int   in_flg;                           /* -in on command line */       /*LP*/
  570. #define IN_FALSE  in_flg = FALSE;                                       /*LP*/
  571. /* Lattice probably does not support multiple line macros */            /*LP*/
  572. #define CHK_IN  ++arg; if (toupper(*arg) == 'N') in_flg++;              /*LP*/
  573. #define I_MESS  i_mes2                                                  /*LP*/
  574. #define OPEN_IN opn_i2                                                  /*LP*/
  575.  
  576. #else                                           /* Other */             /*LP*/
  577. /* Assume other compiler does not support paths for includes */         /*LP*/
  578. #define IN_FALSE                                        /* Dummy */     /*LP*/
  579. #define CHK_IN                                          /* Dummy */     /*LP*/
  580. #define I_MESS  i_mes1                                                  /*LP*/
  581. #define OPEN_IN opn_i1                                                  /*LP*/
  582. #endif                                          /* LATTICE3 */          /*LP*/
  583. #endif                                          /* LATTICE2 */          /*LP*/
  584. #endif                                          /* CIC86 */             /*LP*/
  585.  
  586. /* End of compiler-dependent section                                     */
  587. /*                                                                       */
  588. /*************************************************************************/
  589. /* Preprocessor variables which control changes by L.P.                  */
  590. /* Note that this is the technique for "commenting out" which PC-Lint    */
  591. /* recommends.                                                           */
  592. /*                                                                       */
  593. /* Send the compressed print trailer string to the output file before    */
  594. /* the CPMEOF rather than after it.                                      */
  595. #define LP_EOF  1
  596. /*                                                                       */
  597. /* Remove variable rfptr, declared but not used in function put_token.   */
  598. #define RFPTR_1 0
  599. /*                                                                       */
  600. /* Remove variable f, declared but not used in function chain_alpha      */
  601. #define F_1     0
  602. /*                                                                       */
  603. /* Remove function lst_err, never referenced                             */
  604. #define LST_ERR1 0
  605. /*                                                                       */
  606. /* Remove variable rhsh_cnt, never referenced                            */
  607. #define RHSH_CN1 0
  608. /*                                                                       */
  609. /* Remove variable fil_cnt, never referenced                             */
  610. #define FIL_CNT1 0
  611. /*                                                                       */
  612. /* Remove variable wrd_cnt, never referenced                             */
  613. #define WRD_CNT1 0
  614. /*                                                                       */
  615. /*************************************************************************/
  616.  
  617. #define  NUL0       0
  618. #define  FALSE      0                                                   /*WHR*/
  619. #define  TRUE       1                                                   /*WHR*/
  620. #define  CPMEOF   0x1A                          /* end of file */       /*WHR*/
  621. #define  ERROR    (-1)                                                  /*WHR*/
  622.  
  623. #define  MAX_FILE 65            /* maximum drive:path\file name + */    /*LP*/
  624. #define  MAX_LEN 39  /* maximum identifier length -n opt Lattice C */   /*RSW*/
  625. #define  MAX_WRD   749          /* maximum number of identifiers */
  626. #define  MX_ALPHA  53           /* maximum alpha chain heads */         /*RSW*/
  627. #define  REFS_LIN  8            /* maximum refs per line */             /*RSW*/
  628. #define  LINE_PAG  60   /* note Lattice C gets confused if -n  */       /*RSW*/
  629. /* option is used and #define labels   */
  630. /* are longer than 8 characters        */
  631.  
  632. struct  id_blk
  633. {
  634.    char  id_name[MAX_LEN];
  635.    struct id_blk *alpha_lnk;
  636.    struct rf_blk *top_lnk;
  637.    struct rf_blk *lst_lnk;
  638. } oneid;
  639.  
  640. struct id_blk *id_vector[MAX_WRD];
  641.  
  642. struct alpha_hdr
  643. {
  644.    struct id_blk *alpha_top;
  645.    struct id_blk *alpha_lst;
  646. };
  647.  
  648. struct alpha_hdr alpha_vector[MX_ALPHA];
  649.  
  650. int     y,mo,d;                 /* year,month and day for date */       /*SRJ*/
  651. int     h,mi,s;                 /* hours, minutes, seconds for time */  /*SRJ*/
  652.  
  653. char    *months[]=                      /* month names for date */      /*SRJ*/
  654.                    {
  655.                     "bad month", "January", "February", "March",
  656.                     "April", "May", "June", "July", "August",
  657.                     "September", "October", "November", "December"
  658.                    }
  659. ;
  660.  
  661. int     ln_chr=0;               /* # of characters in the line (for tab) SRJ */
  662.  
  663. unsigned int file_d,file_mo,file_y,file_h,file_mi; /* file m/d/y and h:m  SRJ */
  664.  
  665. FILE    *tb;                                            /* temp fd */   /*SRJ*/
  666.  
  667.  
  668. int     linum;          /* line number */
  669. int     edtnum;         /* edit line number */
  670. #if FIL_CNT1                                                            /*LP*/
  671. int     fil_cnt;        /* active file index */
  672. #endif                                                                  /*LP*/
  673. #if WRD_CNT1                                                            /*LP*/
  674. int     wrd_cnt;        /* token count */
  675. #endif                                                                  /*LP*/
  676. int     pagno;          /* page number */
  677. int     id_cnt;         /* number of unique identifiers */
  678. #if RHSH_CN1                                                            /*LP*/
  679. int     rhsh_cnt;       /* number of conflict hits */
  680. #endif                                                                  /*LP*/
  681. int     filevl;         /* file level  */
  682. int     paglin;         /* page line counter */
  683. int     prt_ref;
  684. char    act_fil[MAX_FILE];                                              /*LP*/
  685. char    lst_fil[MAX_FILE];                                              /*LP*/
  686. char    gbl_fil[MAX_FILE];                                              /*LP*/
  687. FILE   *l_buffer;                                                       /*WHR*/
  688. int     i_flg,o_flg,r_flg,l_flg;
  689. int     debug;
  690. int     c_flg;                                                          /*WHR*/
  691. int   inp_rd;                                                           /*LP*/
  692. int   tab_cnt;                                                          /*LP*/
  693.  
  694.  
  695. /* The following two strings are the compressed print header and the
  696. trailer that returns the printer to the normal mode.  These must
  697. be changed for each printer.  They are currently set up for the   */
  698.  
  699. #if GEMIN10X                                                            /*RSW*/
  700. char cprint_hdr[]="\x1bB\3\1bQ\x84"; /* header string for Gemini-10X */
  701. char cprint_trlr[]="\x1bB\2"; /* ELITE mode trailer string for Gemini-10X */
  702. #endif
  703.  
  704. #if IDSPRISM                                                            /*RSW*/
  705. char    cprint_hdr[] = "\037";  /* header string for Prism 80 */
  706. char    cprint_trlr[] = "\035"; /* trailer string for Prism 80 */
  707. #endif
  708.  
  709. #if EPSONMX                                                             /*RSW*/
  710. char    cprint_hdr[] = "\x1b\x40\x0F\x1BQ\x84";                         /*WHR*/
  711. char    cprint_trlr[] = "\x1b\x40";    /* trailer string for Epson MX */
  712. #endif
  713.  
  714. #if EPSONFX                                                             /*RSW*/
  715. /* DOUBLE STRIKE COMPRESSED mode header string for Epson FX */ /*WHR*/  /*LP*/
  716. char cprint_hdr[]="\x1b!\x14\x1bQ\x84";
  717. /*EMPHASIZED PICA mode trailer string for Epson FX*/                    /*LP*/
  718. char cprint_trlr[]="\x1b!\x8";
  719. #endif
  720.  
  721.  
  722. /* end of printer strings */
  723. /*   MAIN PROGRAM       */                                              /*SRJ*/
  724.  
  725.  
  726. void main(argc,argv)
  727. int     argc;
  728. char    **argv;
  729.  
  730. {
  731.    char  *arg;
  732.    char cc;                                             /* Lattice C */
  733.  
  734. #ifndef NARGS                                                           /*LP*/
  735.    void use_err(void);                                                  /*LP*/
  736.    void proc_file(char *);                                              /*LP*/
  737.    void prnt_tbl(void);                                                 /*LP*/
  738.    void prt_hdr(void);                                                  /*LP*/
  739.    void GETCLOK(void);                                                  /*LP*/
  740.    void GETFTM(void);                                                   /*LP*/
  741.    int  L_IS_FIL(void);                                                 /*LP*/
  742.    void L_FLUSH(void);                                                  /*LP*/
  743. #else                                                                   /*LP*/
  744.    void use_err();                                                      /*LP*/
  745.    void proc_file();                                                    /*LP*/
  746.    void prnt_tbl();                                                     /*LP*/
  747.    void prt_hdr();                                                      /*LP*/
  748.    void GETCLOK();                                                      /*LP*/
  749.    void GETFTM();                                                       /*LP*/
  750.    int  L_IS_FIL();                                                     /*LP*/
  751.    void L_FLUSH();                                                      /*LP*/
  752. #endif                                                                  /*LP*/
  753.  
  754. /*  The parameters      */
  755.  
  756.    if (argc < 2)
  757.       use_err();
  758.    i_flg = r_flg = o_flg = l_flg = inp_rd = FALSE;
  759.    IN_FALSE;            /* Initialize in_flg to FALSE - Lattice only */ /*LP*/
  760.    tab_cnt = TAB_DFLT;                                                  /*LP*/
  761.    debug = FALSE;
  762.    if (gbl_fil[0] == '-')
  763.         use_err();
  764.    while (--argc != 0)
  765.    {
  766.       if (*(arg =* ++argv) == '-')
  767.       {
  768. #if SIDE_1
  769.          cc = *++arg;
  770.          switch(toupper(cc) )
  771. #else                                                                   /*LP*/
  772.          switch( toupper(*++arg) )      /* Has side effect in Lattice C */
  773. #endif                                                                  /*LP*/
  774.          {
  775.  
  776.             case    'I':
  777.                i_flg++;
  778.                CHK_IN;  /* Check for -in, set in_flg - Lattice only */  /*LP*/
  779.                break;
  780.  
  781.             case    'R':
  782.                r_flg++;
  783.                break;
  784.  
  785.             case    'L':
  786.                l_flg++;
  787.                break;
  788.  
  789.             case    'O':
  790.             {
  791.                o_flg++;
  792.                if (!*++arg)                                             /*LP*/
  793.                {                                                        /*LP*/
  794.                   if (--argc       == 0)                                /*LP*/
  795.                      use_err();                                         /*LP*/
  796.                   (void) strcpy(lst_fil,*++argv);                       /*LP*/
  797.                }                                                        /*LP*/
  798.                else                                                     /*LP*/
  799.                   (void) strcpy(lst_fil,arg);                           /*LP*/
  800.                if (lst_fil[0] == '-')
  801.                   use_err();
  802.                if (debug)
  803.                   printf("lst_fil=>%s<",lst_fil);
  804.                break;
  805.             }
  806.  
  807.             case    'D':
  808.                debug++;
  809.                break;
  810.  
  811.             case    'C':                                        /*SRJ*/ /*WHR*/
  812.                c_flg++;
  813.                if (!o_flg)                                              /*LP*/
  814.                {
  815.                   o_flg++;
  816.                   (void) strcpy(lst_fil,"PRN");                         /*SRJ*/
  817.                }
  818.                break;
  819.  
  820.             case  'T':                                                  /*LP*/
  821.                if (!*++arg)                     /* Space after -t.  LP */
  822.                {
  823.                                         /* Point arg to next word.  LP */
  824.                   if (--argc == 0)                                      /*LP*/
  825.                         use_err();                                      /*LP*/
  826.                   arg = *++argv;                                        /*LP*/
  827.                }                                                        /*LP*/
  828.                tab_cnt = 0;                             /* Get tab_cnt.  LP */
  829.                if (isdigit(*arg))                                       /*LP*/
  830.                {                                                        /*LP*/
  831.                   tab_cnt = *arg++ - '0';                               /*LP*/
  832.                   if (isdigit(*arg))                                    /*LP*/
  833.                      tab_cnt = 10 * tab_cnt + (*arg++ - '0');           /*LP*/
  834.                }                                                        /*LP*/
  835.                if ((!tab_cnt) ||                        /* Empty count.  LP */
  836.                (*arg))          /* Count too big or a tramp character.  LP */
  837.                 use_err();                                              /*LP*/
  838.                break;                                                   /*LP*/
  839.  
  840.             default:
  841.                use_err();
  842.          }
  843.       } /* if (*(arg =* ++argv) == '-') */
  844.       else
  845.       {
  846.          if (inp_rd)                                                    /*LP*/
  847.             use_err();
  848.          else
  849.          {                                                              /*LP*/
  850.             inp_rd++;                                                   /*LP*/
  851.             strcpy(gbl_fil,*argv);
  852.             if (!strchr(gbl_fil, '.'))          /* No file extension */ /* LP */
  853.                strcat(gbl_fil, ".c");           /* Add default .c */ /* LP */
  854.          }
  855.       } /*else for if (*(arg =* ++argv) == '-') */
  856.    } /* while (--argc != 0) */
  857.    if (!inp_rd)                                                         /*LP*/
  858.       use_err();                                                        /*LP*/
  859.    if (debug)
  860.       printf("\ni_flg=%d, r_flg=%d, l_flg=%d", i_flg,r_flg,l_flg);
  861.    if (debug)
  862.       printf("\no_flg=%d, debug=%d", o_flg,debug);
  863.    if (o_flg)
  864.    {
  865.       if ( (l_buffer = fopen(lst_fil,"w")) == NUL0)   /*** output file ***/
  866.       {
  867.          printf("ERROR: Unable to create list file - %s\n",lst_fil);
  868.          exit(0);
  869.       }
  870.       printf("\nXC ....... 'C' Print Utility  v1.1\n");                 /*RSW*/
  871.       if (c_flg)
  872.          fprintf(l_buffer,"%s",cprint_hdr);
  873.    }
  874.    else                                                                 /*SRJ*/
  875.         l_buffer=stdout;        /* if no output file, use stdout */     /*SRJ*/
  876.  
  877.    GETCLOK();                   /* Get the system date and time */      /*LP*/
  878.  
  879. /* NOW WE GET THE FILE LATEST UPDATE DATE AND TIME */
  880.  
  881. /* first try to open the file */
  882.  
  883.    if ((tb = fopen(gbl_fil,"r")) == NUL0)  /*open the input file */     /*SRJ*/
  884.    {
  885.       printf("\nERROR: Unable to open input file: %s\n",gbl_fil);       /*SRJ*/
  886.       exit(10);                                                         /*SRJ*/
  887.    }
  888.    GETFTM();                                                            /*LP*/
  889.  
  890.    prt_ref = FALSE;
  891.    for (linum = 0; linum < MAX_WRD; linum++)
  892.       id_vector[linum] = NUL0;
  893.  
  894.    for (linum = 0; linum < MX_ALPHA; linum++)
  895.       alpha_vector[linum].alpha_top =
  896.       alpha_vector[linum].alpha_lst = NUL0;
  897.  
  898. #if FIL_CNT1                                                            /*LP*/
  899.    fil_cnt = 0;                                                         /*LP*/
  900. #endif                                                                  /*LP*/
  901. #if WRD_CNT1                                                            /*LP*/
  902.    wrd_cnt = 0;                                                         /*LP*/
  903. #endif                                                                  /*LP*/
  904.    linum = 0;                                                           /*LP*/
  905.    filevl = paglin = pagno = edtnum = 0;
  906.    id_cnt  = 0;
  907. #if RHSH_CN1                                                            /*LP*/
  908.    rhsh_cnt =0;
  909. #endif                                                                  /*LP*/
  910.    if (GETDYN())                /* Get dynamic memory - Lattice only */ /*LP*/
  911.    {                                                                    /*LP*/
  912.       printf("\nUnable to get dynamic memory\n");                       /*LP*/
  913.       exit(0);                                                          /*LP*/
  914.    }                                                                    /*LP*/
  915.    proc_file(gbl_fil);
  916.    if (!l_flg)
  917.    {
  918.       prnt_tbl();
  919.       printf("\nAllowable Symbols: %d\n", MAX_WRD);
  920.       printf("Unique    Symbols: %d\n", id_cnt);
  921.    }
  922.    RELDYN();            /* Release dynamic memory - Lattice only */     /*LP*/
  923.    if (o_flg)
  924.    {
  925.       fputc('\n',l_buffer);     /* output cr/lf */              /*SRJ*/ /*LP*/
  926.       if (++paglin >= LINE_PAG )                                        /*LP*/
  927.          prt_hdr();                                                     /*LP*/
  928.       fprintf(l_buffer,"\nAllowable Symbols: %d\n", MAX_WRD);           /*WHR*/
  929.       fprintf(l_buffer,"Unique    Symbols: %d\n", id_cnt);              /*WHR*/
  930. #if LP_EOF      /* Send EOF after output trailer string rather than */  /*LP*/
  931.                 /* before it */                                         /*LP*/
  932.       fputc('\f', l_buffer);                                            /*LP*/
  933.       if (c_flg)                /* Only output trailer if -c */         /*LP*/
  934.          fprintf(l_buffer,"%s", cprint_trlr);   /* output trailer */    /*SRJ*/
  935.       fputc(CPMEOF, l_buffer);                                          /*LP*/
  936. #else                                                                   /*LP*/
  937.       fprintf(l_buffer,"\f%c", CPMEOF);                                 /*WHR*/
  938.       if (c_flg)                /* Only output trailer if -c */         /*LP*/
  939.          fprintf(l_buffer,"%s", cprint_trlr);   /* output trailer */    /*SRJ*/
  940. #endif                                                                  /*LP*/
  941.       if (L_IS_FIL())           /* l_buffer is a file */                /*LP*/
  942.       {
  943.          L_FLUSH();                                                     /*LP*/
  944.          if (fclose(l_buffer))                                          /*LP*/
  945.          {                                                              /*LP*/
  946.             printf
  947.                ("\nERROR: Unable to close output file: %s\n", lst_fil); /*LP*/
  948.             exit(0);                                                    /*LP*/
  949.          }                                                              /*LP*/
  950.       }
  951.    }
  952. }
  953. /*    ERROR MESSAGE PRINT ROUTINES */                                   /*SRJ*/
  954.  
  955. #if LST_ERR1                    /* Not used */                          /*LP*/
  956. void lst_err()
  957.  
  958. {
  959.    printf("\nERROR: Write error on list output file - %s\n", lst_fil);
  960.    exit(0);
  961. }
  962. #endif                                                                  /*LP*/
  963.  
  964. void use_err()
  965.  
  966. {
  967. #ifndef NARGS
  968.    void I_MESS(void);
  969. #else
  970.    void I_MESS();
  971. #endif
  972.  
  973.    printf("\nERROR: Invalid parameter specification\n\n");
  974.    printf("Usage: xc <filename> <flag(s)>\n\n");
  975.    printf("Flags: -i             = ");                                  /*LP*/
  976.    I_MESS();                            /* Print message for -i */      /*LP*/
  977.    printf("       -l             = Generate listing only\n");
  978.    printf("       -c             = Compressed print option.  Change the\n");
  979.                                                                 /*SRJ*/  /*LP*/
  980.    printf("                        default output file to the printer\n");
  981.                                                                         /*LP*/
  982.    printf("       -r             = Cross-reference reserved words\n");
  983.    printf("       -o <filename>  = Write output to named file\n");
  984.    printf("       -t <tab_count> = Reset tab count from default %d\n",
  985.           TAB_DFLT);                                                    /*LP*/
  986.    exit(0);
  987. }
  988.  
  989. /*    PROCESS THE FILE  */                                              /*SRJ*/
  990.  
  991. void proc_file(filnam)
  992.  
  993.    char *filnam;
  994.  
  995. {
  996.    FILE *buffer;                /* allocated buffer pointer */          /*WHR*/
  997.    char token[MAX_LEN];         /* token buffer */
  998.    int  eof_flg;                /* end-of-file indicator */
  999.    int  tok_len;                /* token length */
  1000.    int  incnum;                 /* included line number */
  1001. #ifndef NARGS                                                           /*LP*/
  1002.    FILE *OPEN_IN(char *);                                               /*LP*/
  1003.    int get_token(FILE *, char *, int *, int *, int);                    /*LP*/
  1004.    int chk_token(char *);                                               /*LP*/
  1005.    void put_token(char *, int);                                         /*LP*/
  1006.    void prt_hdr(void);                                                  /*LP*/
  1007.    void nl(void);                                                       /*LP*/
  1008. #else                                                                   /*LP*/
  1009.    FILE *OPEN_IN();
  1010.    int get_token();                                                     /*LP*/
  1011.    int chk_token();                                                     /*LP*/
  1012.    void put_token();                                                    /*LP*/
  1013.    void prt_hdr();                                                      /*LP*/
  1014.    void nl();                                                           /*LP*/
  1015. #endif                                                                  /*LP*/
  1016.  
  1017.    (void) strcpy(act_fil,filnam);                                       /*LP*/
  1018.    if ((buffer = OPEN_IN(filnam)) == NUL0) /*** input file ***/ /*WHR*/ /*LP*/
  1019.    {
  1020.       printf("\nERROR: Unable to open input file: %s\n", filnam);
  1021.       exit(0);
  1022.    }
  1023.    if (filevl++ == 0)
  1024.    {
  1025.       prt_hdr();
  1026.       nl();
  1027.    }
  1028.    eof_flg = FALSE;
  1029.    do /* while (!eof_flg) */
  1030.    {
  1031.       if (get_token(buffer, token, &tok_len, &eof_flg, 0))
  1032.       {
  1033.          if (debug)
  1034.             printf("token: %s   length: %d\n", token, tok_len);
  1035.          if (chk_token(token))
  1036.  
  1037. /* #include processing changed to accept drive:   WHR */
  1038.          {
  1039.             if (strcmp(token, "#include") == 0)
  1040.             {
  1041.                if (get_token(buffer, token, &tok_len, &eof_flg,1))
  1042.                {
  1043.                   if (debug)
  1044.                      printf("**token: %s   length: %d\n",
  1045.                             token, tok_len);
  1046.                   if (!i_flg)
  1047.                      continue;
  1048.                   else
  1049.                   {
  1050.                      incnum = edtnum;
  1051.                      edtnum = 0;
  1052.                      nl();
  1053.                      proc_file(token);
  1054.                      edtnum = incnum;
  1055.                      (void) strcpy(act_fil, filnam);
  1056.                      continue;
  1057.                   } /* else for if (!i_flg) */
  1058.                } /* if (get_token(buffer, token, &tok_len, &eof_flg,1)) */
  1059.             } /* if (strcmp(token, "#include") == 0) */
  1060.             put_token(token, linum);
  1061.          } /* if (chk_token(token)) */
  1062.       } /* if (get_token(buffer, token, &tok_len, &eof_flg, 0)) */
  1063.    }
  1064.    while (!eof_flg);
  1065.  
  1066.    filevl -= 1;
  1067.    if (fclose(buffer))                                                  /*LP*/
  1068.    {                                                                    /*LP*/
  1069.       printf("\nERROR: Unable to close input file: %s\n", filnam);      /*LP*/
  1070.       exit(0);                                                          /*LP*/
  1071.    }                                                                    /*LP*/
  1072.    return;
  1073. }
  1074. /*    GET A TOKEN    */                                         /*SRJ*/
  1075.  
  1076. int get_token(g_buffer, g_token, g_toklen, g_eoflg, g_flg)
  1077.  
  1078. FILE    *g_buffer;
  1079.    char    *g_token;
  1080.    int     *g_toklen;
  1081.    int     *g_eoflg;
  1082.    int     g_flg;
  1083.  
  1084. /*
  1085. *        'getoken' returns the next valid identifier or
  1086. *        reserved word from a given file along with the
  1087. *        character length of the token and an end-of-file
  1088. *        indicator
  1089. *
  1090. */
  1091.  
  1092. {
  1093.    int     c;
  1094.    char    *h_token;
  1095. #ifndef NARGS
  1096.    char rdchr(FILE *, int *, int);
  1097. #else
  1098.    char rdchr();
  1099. #endif
  1100.  
  1101.    h_token = g_token;
  1102.  
  1103.    gtk:                          /* top of loop, get new token */
  1104.       *g_toklen = 0;
  1105.       g_token = h_token;
  1106.  
  1107. /*
  1108.      *  Scan and discard any characters until an alphabetic or
  1109.      *  '_' (underscore) character is encountered or an end-of-file
  1110.      *  condition occurs
  1111.      */
  1112.  
  1113.       while (  (!isalpha(*g_token = rdchr(g_buffer, g_eoflg, g_flg)))
  1114.                 &&  !*g_eoflg      &&  *g_token != '_'
  1115.                 && *g_token != '0' &&  *g_token != '#'
  1116.                 && IS_PATH)                                             /*LP*/
  1117.                    ;
  1118.       if (*g_eoflg)
  1119.          return(FALSE);
  1120.  
  1121.       *g_toklen += 1;
  1122.  
  1123. /*
  1124.      *   Scan and collect identified alpanumeric token until
  1125.      *   a non-alphanumeric character is encountered or and
  1126.      *   end-of-file condition occurs
  1127.      */
  1128.  
  1129.       while ( (isalpha(c=rdchr(g_buffer, g_eoflg, g_flg)) ||
  1130.                isdigit(c) || c == '_' ||                                /*LP*/
  1131.                /* Check for extra characters in #include file name */   /*LP*/
  1132.                (g_flg && IS_FCHAR))                                     /*LP*/
  1133.                && !*g_eoflg)              /* WHR fix for B:filename.ext */
  1134.       {
  1135.          if (*g_toklen < MAX_LEN)
  1136.          {
  1137.             *++g_token = c;
  1138.             *g_toklen += 1;
  1139.          }
  1140.       }
  1141.  
  1142.  
  1143. /*
  1144.      *      Check to see if a numeric hex or octal constant has
  1145.      *      been encountered ... if so dump it and try again
  1146.      */
  1147.  
  1148.  
  1149.       if (*h_token == '0')
  1150.          goto gtk;
  1151.  
  1152.  
  1153. /*
  1154.      *      Tack a NUL0 character onto the end of the token
  1155.      */
  1156.  
  1157.       *++g_token = NUL0;
  1158.  
  1159. /*
  1160.      *      Screen out all #token strings except #include
  1161.      */
  1162.  
  1163.       if (*h_token == '#' && strcmp(h_token, "#include"))
  1164.          goto gtk;
  1165.  
  1166.       return (TRUE);
  1167. }
  1168. /*   READ A CHARACTER FROM THE FILE AND PROCESS IT */                   /*SRJ*/
  1169.  
  1170.  
  1171. char rdchr(r_buffer, r_eoflg, rd_flg)                                   /*LP*/
  1172.    FILE    *r_buffer;
  1173.    int     *r_eoflg;
  1174.    int     rd_flg;
  1175.  
  1176. /*
  1177.         'rdchr' returns the next valid character in a file
  1178.         and an end-of-file indicator. A valid character is
  1179.         defined as any which does not appear in either a
  1180.         commented or a quoted string ... 'rdchr' will correctly
  1181.         handle comment tokens which appear within a quoted
  1182.         string
  1183. */
  1184.  
  1185. {
  1186.    int     c;
  1187.    int     q_flg;          /* double quoted string flag */
  1188.    int     q1_flg;         /* single quoted string flag */
  1189.    int     cs_flg;         /* comment start flag */
  1190.    int     ce_flg;         /* comment end flag */
  1191.    int     c_cnt;          /* comment nesting level */
  1192.    int     t_flg;          /* transparency flag */
  1193. #ifndef NARGS                                                           /*LP*/
  1194.    int fil_chr(FILE *, int *);                                          /*LP*/
  1195.    void prt_hdr(void);                                                  /*LP*/
  1196.    void nl(void);                                                       /*LP*/
  1197. #else                                                                   /*LP*/
  1198.    int fil_chr();                                                       /*LP*/
  1199.    void prt_hdr();                                                      /*LP*/
  1200.    void nl();                                                           /*LP*/
  1201. #endif                                                                  /*LP*/
  1202.  
  1203.    q_flg = FALSE;
  1204.    q1_flg = FALSE;
  1205.    cs_flg = FALSE;
  1206.    ce_flg = FALSE;
  1207.    t_flg = FALSE;
  1208.    c_cnt  = 0;
  1209.  
  1210.    rch:
  1211.  
  1212.  
  1213. /*
  1214.      *   Fetch character from file
  1215.      */
  1216.  
  1217.       c = fil_chr(r_buffer, r_eoflg) & 0x7F;
  1218.                                 /* read only 7 bit ascii */             /*SRJ*/
  1219.  
  1220.       if (*r_eoflg)             /* EOF encountered */
  1221.          return((char) c);                                              /*LP*/
  1222.  
  1223.       switch(c)                 /* test the returned character */       /*SRJ*/
  1224.       {
  1225.          case '\n':             /* carriage return */                   /*SRJ*/
  1226.             nl();               /* output new line and line numbers */  /*SRJ*/
  1227.             ln_chr = 0;         /* set to first char in line */         /*SRJ*/
  1228.             c = ' ';            /* return a space */                    /*SRJ*/
  1229.             break;
  1230.  
  1231.          case '\f':             /* form feed */                         /*SRJ*/
  1232.             prt_hdr();          /* output header and start new page*/   /*SRJ*/
  1233.             fprintf(l_buffer, "     ");
  1234.                                 /* space over line #s */                /*SRJ*/
  1235.             ln_chr = 0;         /* set to first char in line */         /*SRJ*/
  1236.             c = ' ';            /* set char to blank */                 /*SRJ*/
  1237.             break;
  1238.  
  1239.          case '\t':             /* tab character */                     /*SRJ*/
  1240.             do                  /* expand the tabs */                   /*SRJ*/
  1241.                fputc(' ', l_buffer);                                    /*SRJ*/
  1242.             while ( (++ln_chr % tab_cnt) != 0);                         /*SRJ*/
  1243.             c = ' ';            /* set char to blank */                 /*SRJ*/
  1244.             break;
  1245.  
  1246.  
  1247.          default:
  1248.             ln_chr++;           /* move to next char pos */             /*SRJ*/
  1249.             if ( iscntrl(c) )   /* insure no control chars */           /*SRJ*/
  1250.                c = ' ';
  1251.             fputc(c, l_buffer); /* and output next char */              /*SRJ*/
  1252.       }
  1253.  
  1254.       if (rd_flg)
  1255.          return((char) c);                                              /*LP*/
  1256.  
  1257.       if (t_flg)
  1258.       {
  1259.          t_flg = !t_flg;
  1260.          goto rch;
  1261.       }
  1262.  
  1263.       if (c == '\\')
  1264.       {
  1265.          t_flg = TRUE;
  1266.          goto rch;
  1267.       }
  1268. /*
  1269.         If the character is not part of a quoted string
  1270.         check for and process commented strings...
  1271.         nested comments are handled correctly but unbalanced
  1272.         comments are not ... the assumption is made that
  1273.         the syntax of the program being xref'd is correct
  1274.         */
  1275.  
  1276.       if (!q_flg  &&  !q1_flg)
  1277.       {
  1278.          if (c == '*'  &&  c_cnt  &&  !cs_flg)
  1279.          {
  1280.             ce_flg = TRUE;
  1281.             goto rch;
  1282.          }
  1283.          if (c == '/'  &&  ce_flg)
  1284.          {
  1285.             c_cnt -= 1;
  1286.             ce_flg = FALSE;
  1287.             goto rch;
  1288.          }
  1289.          ce_flg = FALSE;
  1290.          if (c == '/')
  1291.          {
  1292.             cs_flg = TRUE;
  1293.             goto rch;
  1294.          }
  1295.          if (c == '*'  &&  cs_flg)
  1296.          {
  1297.             c_cnt += 1;
  1298.             cs_flg = FALSE;
  1299.             goto rch;
  1300.          }
  1301.          cs_flg = FALSE;
  1302.  
  1303.          if (c_cnt) goto rch;
  1304.       } /* if (!q_flg  &&  !q1_flg) */
  1305.  
  1306. /*
  1307.         Check for and process quoted strings
  1308.         */
  1309.  
  1310.       if ( c == '"'  &&  !q1_flg)
  1311.       {
  1312. /* toggle quote flag */
  1313.          q_flg =  !q_flg;
  1314.          if (debug)
  1315.             printf("q_flg toggled to: %d\n" , q_flg);
  1316.          goto rch;
  1317.       }
  1318.       if (q_flg) goto rch;
  1319.  
  1320.       if (c == '\'')
  1321.       {
  1322. /* toggle quote flag */
  1323.          q1_flg = !q1_flg;
  1324.          if (debug)
  1325.             printf("q1_flg toggled to: %d\n" , q1_flg);
  1326.          goto rch;
  1327.       }
  1328.       if (q1_flg) goto rch;
  1329.  
  1330. /*
  1331.         Valid character ... return to caller
  1332.         */
  1333.  
  1334.       return ((char) c);                                                /*LP*/
  1335. }
  1336. /*rdchr.
  1337. -----------------------------------------------*/
  1338. int fil_chr(f_buffer,f_eof)                                             /*LP*/
  1339.    FILE *f_buffer;
  1340.    int *f_eof;
  1341.  
  1342. {
  1343.    int  fc;
  1344.  
  1345.    fc = getc(f_buffer);
  1346.    if (fc == CPMEOF || fc == EOF)
  1347.    {
  1348.       *f_eof = TRUE;
  1349.       fc = NUL0;
  1350.    }
  1351.    return(fc);
  1352. }
  1353. /*    CHECK THE TOKEN  */                                               /*SRJ*/
  1354.  
  1355.  
  1356. int chk_token(c_token)                                                  /*LP*/
  1357. char    *c_token;
  1358.  
  1359. {
  1360.    char  u_token[MAX_LEN];
  1361.    int   i;
  1362.  
  1363.    {
  1364.       if (r_flg) return(TRUE);
  1365.       i = 0;
  1366.       do
  1367.       {
  1368.          u_token[i] = toupper(c_token[i]);
  1369.       }
  1370.       while (c_token[i++] != NUL0);
  1371.  
  1372.       switch(u_token[0])
  1373.       {
  1374.          case 'A':
  1375.             if (strcmp(u_token,"AUTO") == 0)
  1376.                return(FALSE);
  1377.             break;
  1378.          case 'B':
  1379.             if (strcmp(u_token,"BREAK") == 0)
  1380.                return(FALSE);
  1381.             break;
  1382.          case 'C':
  1383.             if (strcmp(u_token,"CHAR") == 0)
  1384.                return(FALSE);
  1385.             if (strcmp(u_token,"CONTINUE") == 0)
  1386.                return(FALSE);
  1387.             if (strcmp(u_token,"CASE") == 0)
  1388.                return(FALSE);
  1389.             break;
  1390.  
  1391.          case 'D':
  1392.             if (strcmp(u_token,"DOUBLE") == 0)
  1393.                return(FALSE);
  1394.             if (strcmp(u_token,"DO") == 0)
  1395.                return(FALSE);
  1396.             if (strcmp(u_token,"DEFAULT") == 0)
  1397.                return(FALSE);
  1398.             break;
  1399.          case 'E':
  1400.             if (strcmp(u_token,"EXTERN") == 0)
  1401.                return(FALSE);
  1402.             if (strcmp(u_token,"ELSE") == 0)
  1403.                return(FALSE);
  1404.             if (strcmp(u_token,"ENTRY") == 0)
  1405.                return(FALSE);
  1406.             break;
  1407.          case 'F':
  1408.             if (strcmp(u_token,"FLOAT") == 0)
  1409.                return(FALSE);
  1410.             if (strcmp(u_token,"FOR") == 0)
  1411.                return(FALSE);
  1412.             break;
  1413.          case 'G':
  1414.             if (strcmp(u_token,"GOTO") == 0)
  1415.                return(FALSE);
  1416.             break;
  1417.          case 'I':
  1418.             if (strcmp(u_token,"INT") == 0)
  1419.                return(FALSE);
  1420.             if (strcmp(u_token,"IF") == 0)
  1421.                   return(FALSE);
  1422.             break;
  1423.          case 'L':
  1424.             if (strcmp(u_token,"LONG") == 0)
  1425.                return(FALSE);
  1426.             break;
  1427.          case 'R':
  1428.             if (strcmp(u_token,"RETURN") == 0)
  1429.                return(FALSE);
  1430.             if (strcmp(u_token,"REGISTER") == 0)
  1431.                return(FALSE);
  1432.             break;
  1433.          case 'S':
  1434.             if (strcmp(u_token,"STRUCT") == 0)
  1435.                return(FALSE);
  1436.             if (strcmp(u_token,"SHORT") == 0)
  1437.                return(FALSE);
  1438.             if (strcmp(u_token,"STATIC") == 0)
  1439.                return(FALSE);
  1440.             if (strcmp(u_token,"SIZEOF") == 0)
  1441.                return(FALSE);
  1442.             if (strcmp(u_token,"SWITCH") == 0)
  1443.                return(FALSE);
  1444.             break;
  1445.          case 'T':
  1446.             if (strcmp(u_token,"TYPEDEF") == 0)
  1447.                return(FALSE);
  1448.             break;
  1449.          case 'U':
  1450.             if (strcmp(u_token,"UNION") == 0)
  1451.                return(FALSE);
  1452.             if (strcmp(u_token,"UNSIGNED") == 0)
  1453.                return(FALSE);
  1454.             break;
  1455.          case 'W':
  1456.             if (strcmp(u_token,"WHILE") == 0)
  1457.                return(FALSE);
  1458.             break;
  1459.       }
  1460.    }
  1461.    return (TRUE);
  1462. }
  1463. /*chk_token.
  1464. ---------------------------------------------*/
  1465. /*    STORE THE TOKEN  */                                               /*SRJ*/
  1466.  
  1467. /*
  1468.    *    Install parsed token and line reference in linked structure
  1469.    */
  1470.  
  1471. void put_token(p_token, p_ref)
  1472.    char *p_token;
  1473.    int  p_ref;
  1474.  
  1475. {
  1476.    int  hsh_index;
  1477.    int  i;
  1478.  
  1479. /*   unsigned long j;   */                                              /*SRJ*/
  1480.    long int j;                                                          /*RSW*/
  1481.    int  d;
  1482.    int  found;
  1483.    struct id_blk *idptr;
  1484. #if RFPTR_1                     /* This variable is not used */         /*LP*/
  1485.    struct rf_blk *rfptr;
  1486. #endif                                                                  /*LP*/
  1487.  
  1488. #ifndef NARGS                                                           /*LP*/
  1489.    struct id_blk *alloc_id(char *);                                       /*LP*/
  1490.    struct rf_blk *alloc_rf(int);                                        /*LP*/
  1491.    struct rf_blk *add_rf(struct rf_blk *, int);                         /*LP*/
  1492.    void chain_alpha(struct id_blk *, char *);                             /*LP*/
  1493. #else                                                                   /*LP*/
  1494.    struct id_blk *alloc_id();
  1495.    struct rf_blk *alloc_rf();
  1496.    struct rf_blk *add_rf();
  1497.    void chain_alpha();                                                  /*LP*/
  1498. #endif                                                                  /*LP*/
  1499.  
  1500.    if (l_flg)    return;
  1501.       j = 0;
  1502.    for (i = 0; p_token[i] != NUL0; i++)  /* Hashing algorithm is far from */
  1503.       j = j * 10 + p_token[i];        /* memory-bound index vector!    */
  1504.  
  1505.    hsh_index = j % MAX_WRD;                                             /*SRJ*/
  1506.  
  1507.    if (debug)
  1508.       printf("hash index=%d ", hsh_index);
  1509.  
  1510.    found = FALSE;
  1511.    d = 1;
  1512.    do /* while (!found); */
  1513.    {
  1514.       idptr = id_vector[hsh_index];
  1515.       if (idptr == NUL0)
  1516.       {
  1517.          id_cnt++;
  1518.          idptr = id_vector[hsh_index] = alloc_id(p_token);
  1519.          chain_alpha(idptr, p_token);
  1520.          idptr->top_lnk = idptr->lst_lnk = alloc_rf(p_ref);
  1521.          found = TRUE;
  1522.          if (debug)
  1523.             printf("empty cell in vector\n");
  1524.       }
  1525.       else
  1526.          if (strcmp(p_token, idptr->id_name) == 0)
  1527.          {
  1528.             idptr->lst_lnk = add_rf(idptr->lst_lnk, p_ref);
  1529.             if (debug)
  1530.                printf("duplicate token\n");
  1531.             found = TRUE;
  1532.          }
  1533.          else
  1534.          {
  1535.             hsh_index += d;
  1536.             if (debug)
  1537.                printf("hash clash  hash index=%d\n", hsh_index);
  1538.             d += 2;
  1539. #if RHSH_CN1                                                            /*LP*/
  1540.             rhsh_cnt++;
  1541. #endif                                                                  /*LP*/
  1542.             if (hsh_index >= MAX_WRD)
  1543.                hsh_index -= MAX_WRD;
  1544.             if (d == MAX_WRD)
  1545.             {
  1546.                printf("\nERROR: Symbol table overflow\n");
  1547.                exit(0);
  1548.             }
  1549.          } /* else for if (strcmp(p_token,idptr->id_name) == 0) */
  1550.            /* also else of if (idptr == NUL0) */
  1551.    }
  1552.    while (!found);
  1553.  
  1554.    return;
  1555. }
  1556. /*put_token.
  1557. --------------------------------------------*/
  1558. /*     BUILD THE CHAINS */                                              /*SRJ*/
  1559.  
  1560. void chain_alpha(ca_ptr,ca_token)
  1561.    struct id_blk *ca_ptr;
  1562.    char          *ca_token;
  1563.  
  1564. {
  1565.    char  c;
  1566. #if F_1                 /* Variable not used */                         /*LP*/
  1567.    int   f;
  1568. #endif                                                                  /*LP*/
  1569.    struct id_blk *cur_ptr;
  1570.    struct id_blk *lst_ptr;
  1571. /*** int isupper();   ****/            /** Lattice C   macro **/
  1572.  
  1573.  
  1574.    c = ca_token[0];
  1575.    if (c == '_')  c = 0;
  1576.    else
  1577. /**  isupper(c) ? c=1+((c-'A')*2) : c=2+((c-'a')*2) ;     error or not??
  1578.       **  A good one for the puzzle book! Is the () required around (c=..)?
  1579.       **  C86 and Lattice C both req the ()'s, BDS C did not.
  1580.       **  Is it required because = has lower precedence than ?: ????
  1581.       **/
  1582.       isupper(c) ? (c=1+((c-'A')*2)) : (c=2+((c-'a')*2)) ;
  1583.  
  1584.    if (alpha_vector[c].alpha_top == NUL0)
  1585.    {
  1586.       alpha_vector[c].alpha_top =
  1587.       alpha_vector[c].alpha_lst = ca_ptr;
  1588.       ca_ptr->alpha_lnk = NUL0;
  1589.       return;
  1590.    }
  1591.  
  1592. /*  check to see if new id_blk should be inserted between
  1593.      *  the alpha_vector header block and the first id_blk in
  1594.      *  the current alpha chain
  1595.      */
  1596.  
  1597.    if (strcmp(alpha_vector[c].alpha_top->id_name, ca_token) >0)
  1598.    {
  1599.       ca_ptr->alpha_lnk=alpha_vector[c].alpha_top;
  1600.       alpha_vector[c].alpha_top=ca_ptr;
  1601.       return;
  1602.    }
  1603.  
  1604.    if (strcmp(alpha_vector[c].alpha_lst->id_name, ca_token) < 0)
  1605.    {
  1606.       alpha_vector[c].alpha_lst->alpha_lnk = ca_ptr;
  1607.       ca_ptr->alpha_lnk = NUL0;
  1608.       alpha_vector[c].alpha_lst=ca_ptr;
  1609.       return;
  1610.    }
  1611.  
  1612.    cur_ptr = alpha_vector[c].alpha_top;
  1613.    while (strcmp(cur_ptr->id_name, ca_token) < 0)
  1614.    {
  1615.       lst_ptr = cur_ptr;
  1616.       cur_ptr = lst_ptr->alpha_lnk;
  1617.    }
  1618.  
  1619.    lst_ptr->alpha_lnk = ca_ptr;
  1620.    ca_ptr->alpha_lnk = cur_ptr;
  1621.    return;
  1622. }
  1623. /*chain_alpha.
  1624. -----------------------------------------*/
  1625. /*    GET MEMORY FOR TOKEN TREE */                                      /*SRJ*/
  1626. struct id_blk
  1627.    *alloc_id(aid_token)
  1628.    char  *aid_token;
  1629.  
  1630. {
  1631.    int  ai;
  1632.    struct id_blk *aid_ptr;
  1633.  
  1634.    if ((aid_ptr =  ID_ALLOC) == NULL_PTR)                               /*LP*/
  1635.    {
  1636.       printf("\nERROR: Unable to allocate identifier block\n");
  1637.       exit(0);
  1638.    }
  1639.    ai=0;
  1640.    do
  1641.    {
  1642.       aid_ptr->id_name[ai] = aid_token[ai];
  1643.    }
  1644.    while (aid_token[ai++] != NUL0);
  1645.    return (aid_ptr);
  1646. }
  1647. /*id_blk.
  1648. -----------------------------------------*/
  1649.  
  1650. struct rf_blk
  1651.    *alloc_rf(arf_ref)
  1652.    int  arf_ref;
  1653.  
  1654. {
  1655.    int ri;
  1656.    struct rf_blk *arf_ptr;
  1657.  
  1658.    if ((arf_ptr = RF_ALLOC) == NULL_PTR)                               /*LP*/
  1659.    {
  1660.       printf("\nERROR: Unable to allocate reference block\n");
  1661.       exit(0);
  1662.    }
  1663.    arf_ptr->ref_item[0] = arf_ref;
  1664.    arf_ptr->NEXT_REF = NUL0;    /* Overwrite this setting for CIC86 */  /*LP*/
  1665.    arf_ptr->ref_cnt = 1;
  1666.    for (ri=1; ri < MAX_REF; ri++)
  1667.       arf_ptr->ref_item[ri] = NUL0;
  1668.    return (arf_ptr);
  1669. }
  1670. /*alloc_rf.
  1671. ------------------------------------------*/
  1672. /*    STORE REFERENCE IN TREE */                                        /*SRJ*/
  1673.  
  1674. struct rf_blk
  1675.    *add_rf(adr_ptr,adr_ref)
  1676.  
  1677.    struct rf_blk *adr_ptr;
  1678.    int           adr_ref;
  1679.  
  1680. {
  1681.    struct rf_blk *tmp_ptr;
  1682.  
  1683.    tmp_ptr = adr_ptr;
  1684.    if (adr_ptr->ref_cnt == MAX_REF)
  1685.    {
  1686.       tmp_ptr = adr_ptr->NEXT_REF = alloc_rf(adr_ref);                  /*LP*/
  1687.    }
  1688.    else
  1689.    {
  1690.       adr_ptr->ref_item[adr_ptr->ref_cnt++] = adr_ref;
  1691.    }
  1692.    return (tmp_ptr);
  1693. }
  1694. /*rf_blk.
  1695. ------------------------------------------*/
  1696. /*    PRINT THE CROSS REFERENCE TABLE */                                /*SRJ*/
  1697.  
  1698. void prnt_tbl()
  1699. {
  1700.    int prf_cnt;
  1701.    int pti;
  1702.    int pref;
  1703.    int lin_cnt;
  1704.    struct id_blk *pid_ptr;
  1705.    struct rf_blk *ptb_ptr;
  1706. #ifndef NARGS                                                           /*LP*/
  1707.    void prt_hdr(void);                                                  /*LP*/
  1708.    void nl(void);                                                       /*LP*/
  1709. #else                                                                   /*LP*/
  1710.    void prt_hdr();                                                      /*LP*/
  1711.    void nl();                                                           /*LP*/
  1712. #endif                                                                  /*LP*/
  1713.  
  1714.    prt_ref = TRUE;
  1715.    prt_hdr();
  1716.    if (o_flg)                                                           /*LP*/
  1717.       printf("\nWriting cross-references\n");                           /*LP*/
  1718.    nl();
  1719.    for (pti=0;pti<MX_ALPHA;pti++)
  1720.    {
  1721.       if ((pid_ptr = alpha_vector[pti].alpha_top) != NUL0)
  1722.       {
  1723.          do /* while ((pid_ptr=pid_ptr->alpha_lnk) != NUL0) */
  1724.          {
  1725.             fprintf(l_buffer,"%-14.13s: ", pid_ptr->id_name);           /*WHR*/
  1726.             ptb_ptr = pid_ptr->top_lnk;
  1727.             lin_cnt = prf_cnt = 0;
  1728.             do /* while (pref) */
  1729.             {
  1730.                /* Get another reference block if necessary */           /*LP*/
  1731.                if (prf_cnt == MAX_REF)
  1732.                {
  1733.                   prf_cnt=0;
  1734.                   ptb_ptr = ptb_ptr->NEXT_REF;                          /*LP*/
  1735.                }
  1736.                if (IS_PTR(ptb_ptr)) /* ptb_ptr points to a rf_blk */    /*LP*/
  1737.                {
  1738.                   if ((pref=ptb_ptr->ref_item[prf_cnt++]) != 0)
  1739.                   {
  1740.                      if (++lin_cnt        > REFS_LIN )
  1741.                      {
  1742.                         nl();
  1743.                         fprintf(l_buffer,"%16s", ": ");
  1744.                         lin_cnt = 1;
  1745.                      }
  1746.                      fprintf(l_buffer,"%-4d  ",pref); /*WHR*/
  1747.                   } /* if ((pref=ptb_ptr->ref_item[prf_cnt++]) != 0) */
  1748.                }  /* if (IS_PTR(ptb_ptr)) */
  1749.                else
  1750.                   pref=0;
  1751.             }
  1752.             while (pref);
  1753.             nl();
  1754.             nl();                                                       /*LP*/
  1755.          }
  1756.          while ((pid_ptr = pid_ptr->alpha_lnk) != NUL0);
  1757.       } /* if ((pid_ptr = alpha_vector[pti].alpha_top) != NUL0) */
  1758.    } /* for (pti=0;pti<MX_ALPHA;pti++) */
  1759. }
  1760. /*prnt_tbl.
  1761. ---------------------------------------*/
  1762. /*    TOP OF PAGE AND PRINT THE HEADER */                               /*SRJ*/
  1763.  
  1764. void prt_hdr()
  1765.  
  1766. {
  1767.    fprintf(l_buffer,
  1768.       "\r\f%-10s [file d/t= %d/%02d/%02d  %d:%02d]   [clock d/t= %d %s %d  %d:%02d:%02d]   Page %d\n\n",
  1769.       gbl_fil, file_mo, file_d, file_y, file_h, file_mi,
  1770.       d, months[mo], y, h, mi, s, ++pagno);                             /*SRJ*/
  1771.  
  1772.    paglin =3;
  1773.    return;
  1774. }
  1775. /*   NEW LINE */                                                        /*SRJ*/
  1776.  
  1777. void nl()
  1778.  
  1779. {
  1780.    int digit;                                                           /*LP*/
  1781.  
  1782.    fputc('\n',l_buffer);        /* output cr/lf */                      /*SRJ*/
  1783.  
  1784.    if (++paglin >= LINE_PAG )
  1785.       prt_hdr();
  1786.    if (!prt_ref)
  1787.    {
  1788.       fprintf(l_buffer,"%4d ", ++linum);                                /*SRJ*/
  1789.       if (i_flg)                                                        /*SRJ*/
  1790.          fprintf(l_buffer," %4d: ",++edtnum); /*SRJ*//*WHR*/
  1791.    }
  1792.  
  1793. /* print the status on the console */
  1794.    if (o_flg)
  1795.       if (prt_ref)                                                      /*LP*/
  1796.          putchar('.');                                                  /*LP*/
  1797.       else                              /* Listing program */           /*LP*/
  1798.       {
  1799.          if (linum % 60 == 1)
  1800.             printf("\n<%d>\t", linum);
  1801.          else
  1802.          {                                                              /*LP*/
  1803.             putchar((digit = (linum % 10)) + '0');                      /*LP*/
  1804.             if (!digit)                                                 /*LP*/
  1805.                putchar(' ');                                            /*LP*/
  1806.          }                                                              /*LP*/
  1807.       }
  1808.    return;
  1809. }
  1810. /*nl.
  1811. -------------------------------------------*/
  1812. /*  COMPILER DEPENDENT FUNCTIONS TO GET SYSTEM TIME AND DATE*/             /*LP*/
  1813.  
  1814. #if CIC86                                                               /*LP*/
  1815. /* Computer Innovations C-86 start */                                   /*LP*/
  1816. void getclk_1()
  1817.  
  1818. {
  1819.    void getclk_2();
  1820.  
  1821.    segread(®x);              /* get the segment registers */         /*SRJ*/
  1822.    reg.ds = regx.dsx;           /* save the ds in the sysint data */    /*SRJ*/
  1823.    reg.es = regx.esx;           /* save the es in the sysint data */    /*SRJ*/
  1824.    getclk_2();
  1825. } /* getclk_1.
  1826. -------------------------------------------*/                           /*LP*/
  1827. #endif                                                                  /*LP*/
  1828. #if CIC86 || LATTICE2                                                   /*LP*/
  1829.  
  1830. /* Computer Innovations C-86 and Lattice, Version 2 */                  /*LP*/
  1831. void getclk_2()
  1832.  
  1833. {
  1834. /* THE FOLLOWING CODE GETS THE DATE AND THE TIME FROM DOS.  IT USES THE
  1835. ROUTINES SYSINT AND SEGREAD PROVIDED BY THE CI C-86 LIBRARY.  THIS IS CI C-86
  1836. DEPENDENT CODE AND MUST BE CHANGED FOR OTHER COMPILERS           */     /*SRJ*/
  1837. /* added Lattice C ver 2.00 int86 calls to do the same */               /*RSW*/
  1838.  
  1839. /* get the date */                                                      /*SRJ*/
  1840.    REG.ax = 0x2A00;                     /* date request code */         /*SRJ*/
  1841.    INT21;                               /* DOS interrupt */             /*SRJ*/
  1842.    y = REG.cx;                          /* store year */                /*SRJ*/
  1843.    mo = REG.dx >> 8;                    /* store month */               /*SRJ*/
  1844.    d = REG.dx & 0xFF;                   /* get the day */               /*SRJ*/
  1845.  
  1846. /* get the time */                                                      /*SRJ*/
  1847.    REG.ax = 0x2C00;                     /* time request code */         /*SRJ*/
  1848.    INT21;                               /* DOS interrupt */             /*SRJ*/
  1849.    h = REG.cx >> 8;                     /* get hours */                 /*SRJ*/
  1850.    mi = REG.cx & 0xFF;                  /* get minutes */               /*SRJ*/
  1851.    s = REG.dx >> 8;                     /* get seconds */               /*SRJ*/
  1852. } /* getclk_2.
  1853. -------------------------------------------*/                           /*LP*/
  1854. #endif                                                                  /*LP*/
  1855. #if LATTICE3                                                            /*LP*/
  1856.  
  1857. /* Lattice, Version 3 */                                                /*LP*/
  1858. void getclk_3()                                                         /*LP*/
  1859.  
  1860. /* THE FOLLOWING CODE USES THE NEW LATTICE C VERSION 3.0 FUNCTION GETCLK
  1861. TO GET THE DATE AND TIME. */                                            /*LP*/
  1862.  
  1863. {
  1864.    unsigned char clock[8];                     /* Array for getclk */   /* LP */
  1865.  
  1866.    getclk(clock);                                                       /*LP*/
  1867.    y = clock[1] + 1980;                 /* store year */                /*LP*/
  1868.    mo = clock[2];                       /* store month */               /*LP*/
  1869.    d = clock[3];                        /* get the day */               /*LP*/
  1870.    h = clock[4];                        /* get hours */                 /*LP*/
  1871.    mi = clock[5];                       /* get minutes */               /*LP*/
  1872.    s = clock[6];                        /* get seconds */               /*LP*/
  1873. }  /*getclk_3.
  1874.  
  1875. -------------------------------------------*/                           /*LP*/
  1876. #endif                                                                  /*LP*/
  1877. /*  COMPILER DEPENDENT CODE TO GET A FILE'S TIME AND DATA */               /*LP*/
  1878. #if CIC86                                                               /*LP*/
  1879.  
  1880. /* Computer Innovations C-86 */                                         /*LP*/
  1881. void getft_1()                                                          /*LP*/
  1882.  
  1883. {                                                                       /*LP*/
  1884.    void dosft();                                                        /*LP*/
  1885.    if (fclose(tb))                      /* close the file */    /*SRJ*/ /*LP*/
  1886.    {                                                                    /*LP*/
  1887.       printf(\n"ERROR: Unable to close input file: %s\n", gbl_fil);     /*LP*/
  1888.       exit(0);                                                          /*LP*/
  1889.    }                                                                    /*LP*/
  1890.  
  1891. /* note-we have no way to get an error indication back from the dos call
  1892. below (file open),  so we have to open it to see if it is there before
  1893. we can use the proceedure below */                                      /*SRJ*/
  1894.  
  1895. /* now get the file date and time */                                    /*SRJ*/
  1896.  
  1897. /* open the file   -  we assume the file exists */                      /*SRJ*/
  1898.    REG.ax = 0x3D00;             /* open request code */         /*SRJ*/ /*LP*/
  1899.    REG.dx = gbl_fil;            /* address of file name */      /*SRJ*/ /*LP*/
  1900.    INT21;                       /* DOS interrupt */             /*SRJ*/ /*LP*/
  1901.    handle = REG.ax;             /* store file handle */         /*SRJ*/ /*LP*/
  1902.  
  1903.    dosft();                     /* Get file date and time */            /*LP*/
  1904.  
  1905. /* close the file */                                                    /*SRJ*/
  1906.    REG.bx = handle;                                             /*SRJ*/ /*LP*/
  1907.    REG.ax = 0x3D00;                                             /*SRJ*/ /*LP*/
  1908.    INT21;                       /* DOS interrupt */             /*SRJ*/ /*LP*/
  1909.  
  1910. } /* getft_1.
  1911. -------------------------------------------*/                           /*LP*/
  1912. #endif                                                                  /*LP*/
  1913. #if LATTICE2                                                            /*LP*/
  1914.  
  1915. /* Lattice C, Version 2.0 */                                            /*LP*/
  1916. void getft_2()                                                          /*LP*/
  1917.  
  1918. {                                                                       /*LP*/
  1919.    int  fileno();                                                       /*LP*/
  1920.    void dosft();                                                        /*LP*/
  1921.  
  1922.    handle = fileno(tb);                                                 /*LP*/
  1923.    dosft();                     /* Get file date and time */            /*LP*/
  1924.    if (fclose(tb))                      /* close the file */            /*LP*/
  1925.    {                                                                    /*LP*/
  1926.       printf("\nERROR: Unable to close input file: %s\n", gbl_fil);     /*LP*/
  1927.       exit(0);                                                          /*LP*/
  1928.    }                                                                    /*LP*/
  1929.  
  1930. } /* getft_2.
  1931. -------------------------------------------*/                           /*LP*/
  1932. #endif                                                                  /*LP*/
  1933. #if CIC86 || LATTICE2                                                   /*LP*/
  1934.  
  1935. /* Use DOS calls to get file date and time */                           /*LP*/
  1936.  
  1937. void dosft()                                                            /*LP*/
  1938.  
  1939. {                                                                       /*LP*/
  1940.  
  1941. /* get the date and time */                                             /*SRJ*/
  1942.    REG.ax = 0x5700;             /* time request code */         /*SRJ*/ /*LP*/
  1943.    REG.bx = handle;             /* file handle in bx */         /*SRJ*/ /*LP*/
  1944.    INT21;                       /* DOS interrupt */             /*SRJ*/ /*LP*/
  1945.  
  1946. /* unpack the file time */                                              /*SRJ*/
  1947.    file_h=(REG.cx >> 11) & 0x1F;        /* get hours */         /*SRJ*/ /*LP*/
  1948.    file_mi=(REG.cx >> 5) & 0x3f;        /* get minutes */       /*SRJ*/ /*LP*/
  1949.  
  1950. /* unpack the file date */                                              /*SRJ*/
  1951.    file_d=REG.dx & 0x1F;                   /* get the day */    /*SRJ*/ /*LP*/
  1952.    file_mo= (REG.dx >> 5) & 0x0F;          /* get the month */  /*SRJ*/ /*LP*/
  1953.    file_y=( (REG.dx >> 9) & 0x7F )+80;     /* get the month */  /*SRJ*/ /*LP*/
  1954.  
  1955. } /* dosft.
  1956. -------------------------------------------*/                           /*LP*/
  1957. #endif                                                                  /*LP*/
  1958. #if LATTICE3                                                            /*LP*/
  1959.  
  1960. /* Lattice C, Version 3.0 */                                            /*LP*/
  1961. void getft_3()                                                          /*LP*/
  1962.  
  1963. {                                                                       /*LP*/
  1964.    union FILETIME                                                       /*LP*/
  1965.    {                                                                    /*LP*/
  1966.       long ft_in;                                                       /*LP*/
  1967.       struct DATETIME                                                   /*LP*/
  1968.       {                                                                 /*LP*/
  1969.          struct TIME                                                    /*LP*/
  1970.          {                                                              /*LP*/
  1971.             unsigned hour:5;                                            /*LP*/
  1972.             unsigned minute:6;                                          /*LP*/
  1973.             unsigned second:5;                                          /*LP*/
  1974.          } t;                                                           /*LP*/
  1975.          struct DATE                                                    /*LP*/
  1976.          {                                                              /*LP*/
  1977.             unsigned year:7;                                            /*LP*/
  1978.             unsigned month:4;                                           /*LP*/
  1979.             unsigned day:5;                                             /*LP*/
  1980.          } d;                                                           /*LP*/
  1981.       }    dt;                                                          /*LP*/
  1982.    } ft;                                                                /*LP*/
  1983.  
  1984.    ft.ft_in = getft((int) fileno(tb));                                  /*LP*/
  1985.                                 /* See Lattice C Ver. 3.0 manual */     /*LP*/
  1986.    file_h = ft.dt.t.hour;               /* get hours */                 /*LP*/
  1987.    file_mi = ft.dt.t.minute;            /* get minutes */               /*LP*/
  1988.    file_d = ft.dt.d.day;                /* get the day */               /*LP*/
  1989.    file_mo = ft.dt.d.month;             /* get the month */             /*LP*/
  1990.    file_y = ft.dt.d.year + 80;          /* get the year*/               /*LP*/
  1991.    if (fclose(tb))                      /* close the file */            /*LP*/
  1992.    {                                                                    /*LP*/
  1993.       printf("\nERROR: Unable to close input file: %s\n", gbl_fil);     /*LP*/
  1994.       exit(0);                                                          /*LP*/
  1995.    }                                                                    /*LP*/
  1996.  
  1997. } /* getft_3.
  1998. -------------------------------------------*/                           /*LP*/
  1999. #endif                                                                  /*LP*/
  2000. /*  COMPILER DEPENDENT CODE WHICH RETURNS TRUE IF lbuffer IS A FILE */     /*LP*/
  2001.  
  2002. /* Dummy which always return a value of TRUE */                         /*LP*/
  2003. int l_isf0()                                                            /*LP*/
  2004.  
  2005. {                                                                       /*LP*/
  2006.    return(TRUE);                                                        /*LP*/
  2007. } /* l_isf0.
  2008. -------------------------------------------*/                           /*LP*/
  2009. #if LATTICE2                                                            /*LP*/
  2010.  
  2011. int l_isf2()                                                            /*LP*/
  2012.  
  2013. {                                                                       /*LP*/
  2014.    REG.ax = 0x4400;             /* DOS I/O Control for Devices */       /*LP*/
  2015.    REG.bx = fileno(l_buffer)                                            /*LP*/
  2016.    if (INT21 & 1)               /* Carry flag from DOS interrupt */     /*LP*/
  2017.    {                                                                    /*LP*/
  2018.       printf("\nERROR: Unable to get file characteristics for ");       /*LP*/
  2019.       printf("output file\n");                                          /*LP*/
  2020.       exit(0);                                                          /*LP*/
  2021.    }                                                                    /*LP*/
  2022.    return(!(REG.dx & 0x80));    /* Bit 7 is set if not a disk file */   /*LP*/
  2023. } /* l_isf2().
  2024. -------------------------------------------*/                           /*LP*/
  2025. #endif                                                                  /*LP*/
  2026. #if LATTICE3                                                            /*LP*/
  2027.  
  2028. int l_isf3()                                                            /*LP*/
  2029.  
  2030. {                                                                       /*LP*/
  2031.    int cw;                                                              /*LP*/
  2032.  
  2033.    if (getfc((int) fileno(l_buffer), &cw))                              /*LP*/
  2034.    {                                                                    /*LP*/
  2035.       printf("\nERROR: Unable to get file characteristics for ");       /*LP*/
  2036.       printf("output file\n");                                          /*LP*/
  2037.       exit(0);                                                          /*LP*/
  2038.    }                                                                    /*LP*/
  2039.    return(!(cw & 0x80));        /* Bit 7 is set if not a disk file */   /*LP*/
  2040. } /* l_isf3().
  2041. -------------------------------------------*/                           /*LP*/
  2042. #endif                                                                  /*LP*/
  2043. /*  Flush l_buffer if necessary */                                         /*LP*/
  2044.  
  2045. /* Dummy which does nothing */                                          /*LP*/
  2046. void l_fl0()                                                            /*LP*/
  2047.  
  2048. {                                                                       /*LP*/
  2049.    return;                                                              /*LP*/
  2050. } /* l_fl0
  2051. -------------------------------------------*/                           /*LP*/
  2052. #if CIC86                                                               /*LP*/
  2053.  
  2054. l_fl1                                                                   /*LP*/
  2055.  
  2056. {                                                                       /*LP*/
  2057.    if (fflush(l_buffer))                                                /*LP*/
  2058.    {                                                                    /*LP*/
  2059.       printf                                                            /*LP*/
  2060.          ("\nERROR: Unable to flush output file: %s\n", lst_fil);       /*LP*/
  2061.       exit(0);                                                          /*LP*/
  2062.    }                                                                    /*LP*/
  2063. } /* l_fl1.
  2064. -------------------------------------------*/                           /*LP*/
  2065. #endif
  2066. /*  COMPILER DEPENDENT ERROR MESSAGE FOR -i FLAG */                        /*LP*/
  2067.  
  2068. #if LATTICE3                                                            /*LP*/
  2069.  
  2070. void i_mes2()                                                           /*LP*/
  2071.  
  2072. {                                                                       /*LP*/
  2073.    printf("Enable file inclusion with ");                               /*LP*/
  2074.    printf("extended search\n");                                         /*LP*/
  2075.    printf("                        in directories specified ");         /*LP*/
  2076.    printf("in the environment\n");                                      /*LP*/
  2077.    printf("                        variable named for the ");           /*LP*/
  2078.    printf("include file's file\n");                                     /*LP*/
  2079.    printf("                        name extension and then ");          /*LP*/
  2080.    printf("in the environment\n");                                      /*LP*/
  2081.    printf("                        variable named INCLUDE\n");          /*LP*/
  2082.    printf("       -in            = Enable file inclusion with no ");    /*LP*/
  2083.    printf("extended search\n");                                         /*LP*/
  2084. } /* i_mes2.
  2085. -------------------------------------------*/                           /*LP*/
  2086. #else                                                                   /*LP*/
  2087. void i_mes1()                                                           /*LP*/
  2088.  
  2089. {                                                                       /*LP*/
  2090.    printf("Enable file inclusion\n");                                   /*LP*/
  2091. } /* i_mes1.
  2092. -------------------------------------------*/                           /*LP*/
  2093. #endif                                                                  /*LP*/
  2094. /*  COMPILER DEPENDENT FILE OPEN FOR INPUT FILES */                        /*LP*/
  2095.  
  2096. #if LATTICE3                                                            /*LP*/
  2097.  
  2098. FILE *opn_i2(filnam)                                                    /*LP*/
  2099.  
  2100.    char *filnam;                                                        /*LP*/
  2101.                                                                         /*LP*/
  2102. {                                                                       /*LP*/
  2103.    FILE *buffer;                                                        /*LP*/
  2104.  
  2105.    if (in_flg)                /* No extended directory search. */       /*LP*/
  2106.       buffer = fopen(filnam, "r");               /*** input file ***/   /*WHR*/
  2107.    else         /*  Extended directory search.  Note that since */      /*LP*/
  2108.                 /*  the program earlier got the date and time   */      /*LP*/
  2109.                 /*  the main program from a standard fopen,     */      /*LP*/
  2110.                 /*  the extension does no harm for it. */               /*LP*/
  2111.       buffer = fopene(filnam, "r", "INCLUDE");                          /*LP*/
  2112.    return(buffer);                                                      /*LP*/
  2113. } /* opn_i2.
  2114. -------------------------------------------*/                           /*LP*/
  2115. #else                                                                   /*LP*/
  2116. FILE *opn_i1(filnam)                                                    /*LP*/
  2117.  
  2118.    char *filnam;                                                        /*LP*/
  2119.  
  2120. {                                                                       /*LP*/
  2121.    FILE *buffer;                                                        /*LP*/
  2122.  
  2123.    buffer = fopen(filnam, "r");                 /*** input file ***/   /*WHR*/
  2124.    return(buffer);                                                      /*LP*/
  2125. } /* opn_i1.
  2126. -------------------------------------------*/                           /*LP*/
  2127. #endif                                                                  /*LP*/
  2128. /*============= end of file xc.c ==========================*/
  2129.